package hos.thread

/**
 * <p>Title: PriorityRunnable </p>
 * <p>Description:  </p>
 * <p>Company: www.mapuni.com </p>
 *
 * @author : 蔡俊峰
 * @date : 2023/8/4 21:19
 * @version : 1.0
 */
class PriorityRunnable @JvmOverloads constructor(
    val priority: Int = 0,
    private val runnable: Runnable,
) :
    RunnableThis,
    Comparable<PriorityRunnable> {

    override fun compareTo(other: PriorityRunnable): Int {
        return other.priority.compareTo(priority)
    }

    override fun run() {
        if (runnable is RunnableThis){
            runnable.run(this)
            return
        }
        runnable.run()
    }

    override fun run(run: RunnableThis) {

    }
}